package com.qianfeng.zhangwei.xytg.ui;

import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.widget.RadioGroup;

import com.qianfeng.zhangwei.xytg.R;
import com.qianfeng.zhangwei.xytg.fragment.GroupBuyFragment;
import com.qianfeng.zhangwei.xytg.fragment.MeFragment;
import com.qianfeng.zhangwei.xytg.fragment.MoreFragment;
import com.qianfeng.zhangwei.xytg.fragment.SellerFragment;
import com.qianfeng.zhangwei.xytg.utils.FragmentTabUtils;
import com.qianfeng.zhangwei.xytg.utils.LocationHelper;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity implements FragmentTabUtils.OnRgsExtraCheckedChangedListener {
    private RadioGroup rgs;
    private List<Fragment> fragments = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        rgs = (RadioGroup) this.findViewById(R.id.main_rgs);
        fragments.add(new GroupBuyFragment());
        fragments.add(new SellerFragment());
        fragments.add(new MeFragment());
        fragments.add(new MoreFragment());
        FragmentTabUtils utils = new FragmentTabUtils(getSupportFragmentManager(), fragments, R.id.fragment_main_container, rgs);
        utils.setOnRgsExtraCheckedChangedListener(this);

    }

    @Override
    public void OnRgsExtraCheckedChanged(RadioGroup radioGroup, int checkedId, int index) {

    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        LocationHelper.getInstance().stop();

    }
}
